package com.springboot.redis.demo.controller;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
public class RedisController {

    @Resource
    private RedisTemplate redisTemplate;
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    private int count = 0;

    @PostMapping("stringAndHash")
    public Map<String,Object> testStringAndHash(){
        System.out.println(count++);
        redisTemplate.opsForValue().set("k1","v1");
        redisTemplate.opsForValue().set("int_key","1");
        stringRedisTemplate.opsForValue().set("int","1");

        Map<String,Object> res = new HashMap<>();
        res.put("success",true);
        return res;
    }


}
